Radar Host Communication library  2020.08.13
Protocol.h
Go to the documentation of this file.
1 
46 /* ===========================================================================
47 ** Copyright (C) 2016-2019 Infineon Technologies AG
48 ** All rights reserved.
49 ** ===========================================================================
50 **
51 ** ===========================================================================
52 ** This document contains proprietary information of Infineon Technologies AG.
53 ** Passing on and copying of this document, and communication of its contents
54 ** is not permitted without Infineon's prior written authorisation.
55 ** ===========================================================================
56 */
57 
58 #ifndef PROTOCOL_H_INCLUDED
59 #define PROTOCOL_H_INCLUDED
60 
61 /*
62 ==============================================================================
63  1. INCLUDE FILES
64 ==============================================================================
65 */
66 #include <stdint.h>
67 
68 /* Enable C linkage if header is included in C++ files */
69 #ifdef __cplusplus
70 extern "C"
71 {
72 #endif /* __cplusplus */
73 
74 /*
75 ==============================================================================
76  2. DEFINITIONS
77 ==============================================================================
78 */
79 
91 #define PROTOCOL_STATUS_OK 0x0000
93 #define PROTOCOL_STATUS_DEVICE_TIMEOUT 0x0001
97 #define PROTOCOL_STATUS_DEVICE_BAD_MESSAGE_START 0x0002
100 #define PROTOCOL_STATUS_DEVICE_BAD_ENDPOINT_ID 0x0003
104 #define PROTOCOL_STATUS_DEVICE_NO_PAYLOAD 0x0005
107 #define PROTOCOL_STATUS_DEVICE_OUT_OF_MEMORY 0x0006
111 #define PROTOCOL_STATUS_DEVICE_BAD_PAYLOAD_END 0x0007
115 #define PROTOCOL_STATUS_DEVICE_BAD_COMMAND 0xFFFF
138 /* Theese are the general errors. */
139 #define PROTOCOL_ERROR_INVALID_HANDLE -1
146 /* These error codes are returned when the connection could not be
147  * established.
148  */
149 #define PROTOCOL_ERROR_COULD_NOT_OPEN_COM_PORT -100
152 #define PROTOCOL_ERROR_DEVICE_NOT_COMPATIBLE -101
158 /* These error codes are returned when an error occurs during message
159  * reception.
160  */
161 #define PROTOCOL_ERROR_RECEIVED_NO_MESSAGE -1000
164 #define PROTOCOL_ERROR_RECEIVED_TIMEOUT -1001
169 #define PROTOCOL_ERROR_RECEIVED_BAD_MESSAGE_START -1002
173 #define PROTOCOL_ERROR_RECEIVED_BAD_MESSAGE_END -1003
179 /* These error codes are returned when a wrong endpoint is requested. */
180 #define PROTOCOL_ERROR_ENDPOINT_DOES_NOT_EXIST -2000
183 #define PROTOCOL_ERROR_ENDPOINT_WRONG_TYPE -2001
187 #define PROTOCOL_ERROR_ENDPOINT_VERSION_TOO_OLD -2002
192 #define PROTOCOL_ERROR_ENDPOINT_VERSION_TOO_NEW -2003
200 /*
201 ==============================================================================
202  3. TYPES
203 ==============================================================================
204 */
217 typedef struct
218 {
219  char* description;
221  uint16_t version_major;
222  uint16_t version_minor;
223  uint16_t version_build;
225 
226 
234 typedef struct
235 {
236  uint32_t type;
238  uint16_t version;
240  const char* description;
245 
246 /*
247 ==============================================================================
248  5. FUNCTION PROTOTYPES AND INLINE FUNCTIONS
249 ==============================================================================
250 */
251 
279 int32_t protocol_connect(const char* port_name);
280 
291 void protocol_disconnect(int32_t protocol_handle);
311 int32_t protocol_get_num_endpoints(int32_t protocol_handle);
312 
333 int32_t protocol_get_firmware_information(int32_t protocol_handle,
334  Firmware_Information_t* information);
335 
351 int32_t protocol_do_firmware_reset(int32_t protocol_handle);
352 
376 int32_t protocol_get_endpoint_info(int32_t protocol_handle, uint8_t endpoint,
377  Endpoint_Info_t* endpoint_info);
378 
399 const char* protocol_get_status_code_description(int32_t protocol_handle,
400  int32_t status_code);
401 
402 int32_t protocol_poll_receive_once(int32_t protocol_handle);
403 /* --- Close open blocks -------------------------------------------------- */
404 
405 /* Disable C linkage for C++ files */
406 #ifdef __cplusplus
407 } /* extern "C" */
408 #endif /* __cplusplus */
409 
410 /* End of include guard */
411 #endif /* PROTOCOL_H_INCLUDED */
412 
413 /* --- End of File -------------------------------------------------------- */
This structure contains information about the firmware.
Definition: Protocol.h:273
int32_t protocol_do_firmware_reset(int32_t protocol_handle)
This function triggers a firmware reset of the connected device.
Definition: Protocol.c:846
int32_t protocol_poll_receive_once(int32_t protocol_handle)
Definition: Protocol.c:1151
int32_t protocol_get_num_endpoints(int32_t protocol_handle)
This function returns the number of endpoints in the connected device.
Definition: Protocol.c:755
This structure contains information about an endpoint.
Definition: Protocol.h:290
int32_t protocol_get_endpoint_info(int32_t protocol_handle, uint8_t endpoint, Endpoint_Info_t *endpoint_info)
This function returns information about the requested endpoint.
Definition: Protocol.c:890
int32_t protocol_connect(const char *port_name)
This function establishes a connection to a device through a COM port.
Definition: Protocol.c:573
void protocol_disconnect(int32_t protocol_handle)
This function closes an open connection.
Definition: Protocol.c:723
int32_t protocol_get_firmware_information(int32_t protocol_handle, Firmware_Information_t *information)
This function returns the information about the firmware of the connected device.
Definition: Protocol.c:768
const char * protocol_get_status_code_description(int32_t protocol_handle, int32_t status_code)
This function returns a human readable description of a status or error code.
Definition: Protocol.c:1023